import ProForm, { ProFormProps } from '@/components/ProForm/index.vue';
import { ComponentPublicInstance, CSSProperties } from 'vue';

export interface basicForm {
  options: optionsProps[];
  minWidth?: Number;
  labelWidth?: Array<number>;
  visible: boolean;
  title: string;
  width?: string;
  formCols?: number;
  formAttrs?: FormProps;
  transitionArr?: transitionProp[];
  saveForm?: (params?: any) => void;
}

export interface customForm<T = any> extends basicForm {
  form: T;
}
export interface optionsProps {
  type: 'input' | 'select' | 'time-picker' | 'date-picker' | 'cascader' | 'cascader-panel' | 'time-select' | 'upload';
  label: string;
  prop: string;
  hide: boolean;
  cols?: number;
  defaultValue?: string | number | boolean | any[] | Date;
  attrs?: attrsProps;
  children?: childrenProps[];
  rules?: FormItemRules[];
  changeMethod?: (params?: any) => void;
  inputMethod?: (params?: any) => void;
  blurFunction?: (params?: any) => void;
  calendarChange?: (params?: any) => void;
}

export interface childrenProps {
  label: string;
  value: string | number;
  type?: 'option';
  children?: childrenProps[];
}
export interface attrsProps {
  placeholder?: string;
  props?: any;
  type?: 'textarea' | 'date' | 'number' | 'month' | 'datetime' | 'dates' | '';
  valueFormat?: string;
  format?: string;
  start?: string;
  step?: string;
  end?: string;
  style?: CSSProperties;
  loading?: boolean;
  clearable?: Boolean;
  disabled?: Boolean;
  multiple?: Boolean;
  filterable?: Boolean;
  showAllLevels?: Boolean;
  options?: childrenProps[];
  remote?: Boolean;
  'reserve-keyword'?: Boolean;
  'remote-method'?: (query: string) => void;
  'value-format'?: string;
  'show-password'?: boolean;
}
export interface FormProps {
  labelWidth?: string | number;
  labelPosition?: 'left' | 'right' | 'top';
  inline?: boolean;
}
export interface FormItemRules {
  required?: boolean;
  message?: string;
  validator?: Function;
  trigger: 'blur' | 'change';
}

export interface transitionProp {
  newField: string;
  oldField: string;
}
export type ProFormInstance = Omit<InstanceType<typeof ProForm>, keyof ComponentPublicInstance | keyof ProFormProps>;
